package com.nowcoder.code.lcof;

import java.util.Arrays;

public class JZ61 {

    public static void main(String[] args) {
        System.out.println(new JZ61().IsContinuous(new int[]{1,0,0,1,0}));

    }

    public boolean IsContinuous(int[] numbers) {

        int[] ns = new int[numbers.length];


        int num0 = 0;

        int min = 10000;
        for (int number : numbers) {
            if (number == 0) {
                num0++;
                continue;
            }
            if (number < min) {
                min = number;
            }
        }

        for (int i = 0; i < ns.length; i++) {
            if (numbers[i] == 0) {
                continue;
            }
            int index = numbers[i] - min;
            if (index >= ns.length) {
                return false;
            }
            if (ns[index] != 0) {
                return false;
            }
            ns[index] = numbers[i];
        }

        for (int num : ns) {
            if (num == 0) {
                num0--;
                if (num0 < 0) {
                    return false;
                }
            }
        }

        return true;
    }

}
